class Solution {
public:
    int numWays(int steps, int arrLen) {
    	vector<vector<int>> f; 
    	int min_j = min(steps,arrLen-1);
    	for(int j = 0; j <= min_j; j++) f[0][j] = 0;

    	for(int i = 1; i <= steps; ++i){
    		for(int j = 0; j <= min_j; ++j){
    			if(j==0) f[i][j]=f[i-1][j];
    			if(j>=1 && j<= min_j) f[i][j] = f[i-1][j]+f[i-1][j]+f[i-1][j];
    		}
    	}
    	return f[steps][0];
    } 
};
